#version 430 
layout(location= 100)uniform vec4 uColor;

out vec4 outColor;

vec3 lightDir =  vec3(0, -2, -1);

in vec3 vpos;
in vec3 vnormal;
in vec3 veye;

void main()
{
	vec3 halfVec = normalize(veye - vpos) - normalize(lightDir);
	halfVec =normalize(halfVec);
	vec3 normal = normalize(vnormal);
	float r = max(dot(halfVec, normal), 0);
	float diffuse =  max(dot(normal, -lightDir) , 0) *0.2;
	outColor.rgb = uColor.rgb*
	           (0.4 + diffuse) + vec3(1.0) *(r *0.1 + pow(r, 50)*0.1 );
	outColor.a = uColor.a;
}